
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.inject.Inject;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Mike
 */
@ManagedBean
@ViewScoped
public class Bean {
    private Long country_id=0L;  // select the first option in the combo
    private Long city_id=0L;    // select the first option in the combo
    private @Inject Dao dao;
    private List<Country> countries;  
    private List<City> cities;
 
    public List<Country> getCountries() {
       
        if(countries==null)
            countries=dao.getCountries();
        return countries;
    }
   
    public List<City> getCities() {
       
        if(cities==null)
           cities=dao.getCities(getCountry_id());
        return cities;
    }
 
    public void setCountry_id(Long country_id) {
 
           this.country_id=country_id;
           cities=null;
     }

    /**
     * @return the country_id
     */
    public Long getCountry_id() {
        return country_id;
    }

    /**
     * @return the city_id
     */
    public Long getCity_id() {
        return city_id;
    }

    /**
     * @param city_id the city_id to set
     */
    public void setCity_id(Long city_id) {
        this.city_id = city_id;
    }
    
}
